//
//  HXGiftCollectionViewCell.m
//  GiftSay
//
//  Created by laohu on 16/1/12.
//  Copyright © 2016年 liyinkai. All rights reserved.
//

#import "HXGiftCollectionViewCell.h"

@implementation HXGiftCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:@"NightModeOpen" object:nil];
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:@"NightModeOff" object:nil];
        [self createView];
    }
    return self;
}
//- (void)refresh {
//    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NightMode"] == YES) {
//        self.image.backgroundColor = kNightModeColor1;
//        self.label.backgroundColor = kNightModeColor1;
//        self.label.textColor = [UIColor whiteColor];
//    } else {
//        self.image.backgroundColor = [UIColor whiteColor];
//        self.label.backgroundColor = [UIColor whiteColor];
//        self.label.textColor = [UIColor blackColor];
//    }
//}
- (void)setSecondModel:(HXGiftSecondModel *)secondModel {
    _secondModel = secondModel;
    [self.image setImageWithURL:[NSURL URLWithString:secondModel.icon_url] placeholder:nil];
    self.label.text = self.secondModel.name;
    
}
- (void)createView {
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height * 3 / 4)];
    
    [self addSubview:_image];
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.image.bottom, self.width * 3 /4, self.height / 4)];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.font = [UIFont systemFontOfSize:12 * SCREEN_WIDTH];
    
//    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NightMode"] == YES) {
//        self.image.backgroundColor = kNightModeColor1;
//        self.label.backgroundColor = kNightModeColor1;
//        self.label.textColor = [UIColor whiteColor];
//    } else {
//        self.image.backgroundColor = [UIColor whiteColor];
//        self.label.backgroundColor = [UIColor whiteColor];
//        self.label.textColor = [UIColor blackColor];
//    }
    [self addSubview:_label];
}
@end
